package com.droidclaimcustomer.dal;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class ClaimInfoDBHelper extends SQLiteOpenHelper {
	public static final String DATABASE_TABLE 	= "claiminfo";
	public static final String DATABASE_NAME 	= "droidclaim.db";
	public static final int DATABASE_VERSION 	= 3;

	public static final String KEY_ID 				= "id";
	public static final String KEY_CLAIM_ID 		= "claimid";
	public static final String KEY_ACC_DATE 		= "accidentDate";
	public static final String KEY_ACC_LOCATION 	= "accidentLocation";
	public static final String KEY_ACC_LATITUDE 	= "accidentLatitude";
	public static final String KEY_ACC_LONGITUDE 	= "accidentLongitude";
	public static final String KEY_UPDATE_DATE 		= "updateDate";
	public static final String KEY_STATUS 			= "status";
	public static final String KEY_LICENSEPLATENO 	= "licenseplateNo";
	public static final String KEY_SURVNAME 		= "survName";
	public static final String KEY_SURVMOBILE 		= "survMobile";
	public static final String KEY_IMG_PATH 		= "survImgPath";

	private final String DATABASE_CREATE 		= "create table " + 
			DATABASE_TABLE + " (" + KEY_ID + " integer primary key autoincrement, " +
			KEY_CLAIM_ID + " integer, " +
			KEY_ACC_DATE + " varchar(256), " + 
			KEY_ACC_LOCATION + " varchar(256), " + 
			KEY_ACC_LATITUDE + " numberric, " + 
			KEY_ACC_LONGITUDE + " numberric, " + 
			KEY_UPDATE_DATE + " varchar(256), " + 
			KEY_STATUS + " integer, " + 
			KEY_LICENSEPLATENO + " varchar(32), " + 
			KEY_SURVNAME + " varchar(256), " + 
			KEY_SURVMOBILE + " varchar(10), " + 
			KEY_IMG_PATH + " varchar(512));";
	
	public ClaimInfoDBHelper(Context context, String name,CursorFactory factory, int version) {
		super(context, name, factory, version);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
        db.execSQL(DATABASE_CREATE);	
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// drop table if exist
		db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE);
        // Create a new one.
        onCreate(db);
	}
}